﻿using Domain.Process_Procedures;
using Domain.Production_Modules;
using Infratructure.Interface;
using MediatR;
using MES.Server.API.Application.Command.Production_Modules;
using MES.Server.API.Application.Command.Production_Modules.Pulldown;
using ReturnValue;

namespace MES.Server.API.Application.Handler.Production_Modules.Pulldown
{
    public class GetWarehouseQueryCommandHandler : IRequestHandler<GetWarehouseQueryCommand, ApiResult<List<WarehouseModel>>>
    {
        private readonly IRepository<WarehouseModel> ProductionLineRepo;
        public GetWarehouseQueryCommandHandler(IRepository<WarehouseModel> ProductionLineRepo)
        {
            this.ProductionLineRepo = ProductionLineRepo;
        }
        public Task<ApiResult<List<WarehouseModel>>> Handle(GetWarehouseQueryCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<WarehouseModel>> result = new ApiResult<List<WarehouseModel>>();
            result.Code = StatusCode.Success;
            result.Message = StatusCode.Success.ToString();
            var list = ProductionLineRepo.GetAll();
            result.Data = list.ToList();
            return Task.FromResult(result);
        }
    }
}
